package com.guo.hui.system.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.tomcat.jni.Mmap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.guo.hui.controller.BaseController;
import com.guo.hui.dao.shiro.TpUserMapper;
import com.guo.hui.enumtype.DelFlag;
import com.guo.hui.model.blog.TpArticle;
import com.guo.hui.model.shiro.TpUser;
import com.guo.hui.page.PageParam;
import com.guo.hui.page.PageResult;
import com.guo.hui.service.TpUserShiroService;
import com.guo.hui.util.UtilJson;

@Controller
@RequestMapping("/system/user")
public class UserController extends BaseController {

	@Autowired
	private TpUserShiroService userService;
	@Autowired
	private TpUserMapper userDao;

	@RequestMapping("/index")
	public String index() {
		return "sys/index";
	}

	@RequestMapping("/user")
	public String user() {
		return "sys/user";
	}

	@ResponseBody
	@RequestMapping(value = "/userdata", produces = "text/html;charset=UTF-8")
	public String userdata(Model mm, int page, int rows, @RequestParam String pageParam) {
		PageParam pageParm = (PageParam) UtilJson.fromJson(pageParam, PageParam.class);
		pageParm.setPage(page);
		pageParm.setPageSize(rows);
		PageInfo<TpUser> list = userService.selectByMapPage(pageParm);
		PageResult result = new PageResult();
		result.setTotal((int) list.getTotal());
		result.setRows(list.getList());
		return UtilJson.toJson(list);
	}

}
